//
//  TF1to16PodiumConfiguration.swift
//  TalkfunSDKDemo
//
//  Created by 莫瑞权 on 2022/5/9.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit

class TF1to16PodiumConfiguration: TFTouchBlockView {
//讲台相关
    @objc public let onPodium = TFCenteredleLabel()
    //投票
    @objc public let vote = TFCenteredleLabel()
    //提问
    @objc public let askQuestions = TFCenteredleLabel()
    let view = UIView()
    let btnArray = NSMutableArray()
    override init(frame: CGRect) {
        super.init(frame: frame)

        self.addSubview(self.view)
        
        self.onPodium.fullScreen = 2
        self.vote.fullScreen = 2
        self.askQuestions.fullScreen = 2
        
        self.onPodium.setImage(UIImage.init(named: "HTLive.bundle/applyForPodium1vN"), for: .normal)
        self.vote.setImage(UIImage.init(named: "HTLive.bundle/vote1vN"), for: .normal)
        self.askQuestions.setImage(UIImage.init(named: "HTLive.bundle/askAQuestion1vN"), for: .normal)
        
        self.onPodium.backgroundColor = UIColor(red: 20/255.0, green: 24/255.0, blue: 28/255.0 , alpha: 1)
        self.vote.backgroundColor = UIColor(red: 20/255.0, green: 24/255.0, blue: 28/255.0 , alpha: 1)
        self.askQuestions.backgroundColor = UIColor(red: 20/255.0, green: 24/255.0, blue: 28/255.0 , alpha: 1)
        
        self.view.addSubview(self.onPodium)
        self.view.addSubview(self.vote)
        self.view.addSubview(self.askQuestions)
       
        self.btnArray.add(self.onPodium)
        self.btnArray.add(self.vote)
        self.btnArray.add(self.askQuestions)

    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let viewH:CGFloat = 44*3+20
        var Y:CGFloat = 0
        
        if (TalkfunSharedTools.getMainScreen().size.height <= 320) {
            Y = 10
        }
       
        self.view.frame = CGRect(x: 0, y: (self.frame.size.height - viewH)/2 - Y, width: self.frame.size.width, height: viewH)
        
        for i in 0..<self.btnArray.count {
            let btn =  self.btnArray[i] as! TFCenteredleLabel
            let vcH:CGFloat = 44
            let vcW:CGFloat = vcH
            btn.frame = CGRect(x: 0, y:  CGFloat(i)*vcH + (CGFloat(i)*10), width: vcW, height: vcH)
            btn.layer.masksToBounds = true
            btn.layer.cornerRadius =  vcH/2
        }
    }
    
    @objc public func podiumStatus(_ status:TalkfunApplyStatus)

    {

        if (status == .noApply) {
            self.onPodium.setImage(UIImage.init(named: "HTLive.bundle/applyForPodium1vN"), for: .normal)
           
        }else if (status == .applying) {
            self.onPodium.setImage(UIImage.init(named: "HTLive.bundle/Applying1vN"), for: .normal)
        
        }else{
            self.onPodium.setImage(UIImage.init(named: "HTLive.bundle/agreeToApply1vN"), for: .normal)
            
        }

       
    }
  
}
